﻿<UserControl x:Class="Sonce.Core.Page"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:v="clr-namespace:Sonce.Views"
  xmlns:c="clr-namespace:Sonce.Controls;assembly=Sonce.Controls"
  xmlns:e="clr-namespace:Sonce.Editor;assembly=Sonce.Editor"
  xmlns:data="clr-namespace:Sonce.Database;assembly=Sonce.Database"
  xmlns:s="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
  xmlns:m="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls"
	xmlns:t="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls"
  KeyDown="UserControl_KeyDown">
  <Grid x:Name="LayoutRoot" Background="White">
    <!--xmlns:t="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"-->
    <Grid.RowDefinitions>
      <RowDefinition Height="22"/>
      <RowDefinition Height="30"/>
      <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <c:Menu x:Name="menu" Grid.Row="0" Grid.RowSpan="1" Width="Auto" Background="#FF3A3A3A" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemClick="menu_ItemClick">
      <c:MenuItem Header="File" IsExpanded="True">
        <c:MenuItem Header="New" IsExpanded="True">
          <c:MenuItem Header="Project" />
          <c:MenuItem Header="Solution">
            <c:MenuItem x:Name="prj" Header="Project" />
            <c:MenuItem Header="Solution" />
          </c:MenuItem>
        </c:MenuItem>
        <c:MenuItem Header="Open">
          <c:MenuItem Header="Project" />
          <c:MenuItem Header="Solution" />
        </c:MenuItem>
        <c:MenuItem Header="Save" />
        <c:MenuSeparator />
        <c:MenuItem Header="Close" />
      </c:MenuItem>
      <c:MenuItem Header="Edit" />
      <c:MenuItem Header="View" />
      <c:MenuItem Header="Window" IsEnabled="False" />
    </c:Menu>

    <Grid Grid.Row="1" Background="#FF333333" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.RowSpan="1" Width="Auto">
      <StackPanel Margin="1" Orientation="Horizontal">
        <Border Margin="2" CornerRadius="3,3,3,3" Background="#FF424242">
          <StackPanel Orientation="Horizontal">
            <c:Toolbar x:Name="toolbar" Orientation="Horizontal" ItemClick="toolbar_ItemClick">
              <c:ToolbarButton Icon="../Resources/icon_1.png" />
              <c:ToolbarSeparator Layout="Horizontal" />
              <c:ToolbarButton Icon="../Resources/icon_2.png" />
            </c:Toolbar>
          </StackPanel>
        </Border>

      </StackPanel>
    </Grid>

    <Grid Grid.Column="0" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="30"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Grid Grid.Column="0" Background="#FF333333">
        <c:Toolbar Margin="2" Orientation="Vertical" ItemClick="toolbar_ItemClick">
          <c:ToolbarButton Icon="../Resources/icon_1.png" />
          <c:ToolbarSeparator Layout="Vertical" />
          <c:ToolbarButton Icon="../Resources/icon_2.png" />
        </c:Toolbar>
        <StackPanel Margin="2" Orientation="Vertical" Visibility="Collapsed">
          <Button Style="{StaticResource ToolbarButtonStyle}" Content="../Resources/icon_1.png" />
          <Button Style="{StaticResource ToolbarButtonStyle}" Content="../Resources/icon_2.png" />
          <Rectangle Width="20" Height="1" Margin="0,2,0,2" Fill="#FFB7B7B7" />
          <Button Style="{StaticResource ToolbarButtonStyle}" Content="../Resources/icon_3.png" />
          <Button Style="{StaticResource ToolbarButtonStyle}" Content="../Resources/icon_4.png" />
          <Button Style="{StaticResource ToolbarButtonStyle}" Content="../Resources/icon_5.png" />
        </StackPanel>
      </Grid>
      <Grid Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="5"/>
          <ColumnDefinition Width="250"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="Auto" Width="Auto">
          <Grid.RowDefinitions>
            <RowDefinition Height="4*"/>
            <RowDefinition Height="5"/>
            <RowDefinition x:Name="rdExtra" Height="0*"/>
          </Grid.RowDefinitions>
          <Grid Grid.Row="0" Background="#333333">
            <ScrollViewer Margin="0,0,0,22" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" Style="{StaticResource ScrollViewerStyle}">
              <ScrollViewer.Background>
                <LinearGradientBrush EndPoint="16,16" StartPoint="8,8" SpreadMethod="Repeat" MappingMode="Absolute">
                  <GradientStop Color="#FF2F2F2F" Offset="0"/>
                  <GradientStop Color="#FF2F2F2F" Offset="0.5"/>
                  <GradientStop Color="#FF2D2D2D" Offset="0.5"/>
                  <GradientStop Color="#FF2D2D2D" Offset="1"/>
                </LinearGradientBrush>
              </ScrollViewer.Background>
              <!--Grid Width="1000" Height="600">
                <Rectangle Fill="#FFFFFFFF" Stroke="#FF000000" StrokeThickness="2" Margin="50,50,50,50" />
              </Grid-->
              <e:Editor x:Name="editor" Width="2000" Height="2000" HorizontalAlignment="Left" VerticalAlignment="Top" />
            </ScrollViewer>
          </Grid>
          <s:GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Style="{StaticResource GridSplitterStyle}" />
          <!-- Extra panel - region below the editor -->
          <Grid x:Name="pnlExtra" Grid.Row="2">
            <data:DataViewer x:Name="dvViewer" />
            <TextBox x:Name="txtNotes" Visibility="Collapsed" Text="Write notes here..." HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" Style="{StaticResource TextBoxStyle}" />
          </Grid>
        </Grid>
        <s:GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Style="{StaticResource GridSplitterStyle}" />
        <Grid Grid.Column="2" Background="#333333">
          <ScrollViewer Style="{StaticResource ScrollViewerStyle}" BorderThickness="0,0,0,0">
            <StackPanel>
              <!-- Library Expander -->
              <t:Expander Header="Library" IsExpanded="True" Style="{StaticResource ExpanderStyle}" Margin="0,0,0,0">
                <t:TreeView x:Name="tree" Style="{StaticResource TreeViewStyle}" Margin="5,0,5,5" MaxHeight="400" SelectedItemChanged="tree_SelectedItemChanged">
                  <t:TreeViewItem Header="Root" IsExpanded="True">
                    <t:TreeViewItem Header="Item" />
                    <t:TreeViewItem Header="Item">
                      <t:TreeViewItem Header="Item" />
                      <t:TreeViewItem Header="Item" />
                    </t:TreeViewItem>
                    <t:TreeViewItem Header="Item" IsExpanded="True">
                      <t:TreeViewItem Header="Item" />
                      <t:TreeViewItem Header="Item" />
                    </t:TreeViewItem>
                  </t:TreeViewItem>
                </t:TreeView>
              </t:Expander>
              <!-- Properties Expander -->
              <t:Expander Header="Properties" IsExpanded="True" Style="{StaticResource ExpanderStyle}" Margin="0,0,0,0">
                <StackPanel Orientation="Vertical" Margin="5,5,5,0">
                  <StackPanel Margin="0,0,0,5" Orientation="Horizontal">
                    <TextBlock Text="Name:" Width="70" VerticalAlignment="Center" TextAlignment="Right" Margin="0,0,5,0" />
                    <TextBox Text="R101" Width="140" HorizontalAlignment="Stretch" VerticalAlignment="Center" Style="{StaticResource InputTextBoxStyle}" />
                  </StackPanel>
                  <StackPanel Margin="0,0,0,5" Orientation="Horizontal">
                    <TextBlock Text="Value:" Width="70" VerticalAlignment="Center" TextAlignment="Right" Margin="0,0,5,0" />
                    <TextBox Text="100 ohm" Width="140" HorizontalAlignment="Stretch" VerticalAlignment="Center" Style="{StaticResource InputTextBoxStyle}" />
                  </StackPanel>
                  <StackPanel Margin="0,0,0,5" Orientation="Horizontal">
                    <TextBlock Text="Comment:" Width="70" VerticalAlignment="Center" TextAlignment="Right" Margin="0,0,5,0" />
                    <TextBox Text="Resistor" Width="140" HorizontalAlignment="Stretch" VerticalAlignment="Center" Style="{StaticResource InputTextBoxStyle}" />
                  </StackPanel>
                  <StackPanel Margin="0,0,0,5" Orientation="Horizontal">
                    <TextBlock Text="Category:" Width="70" VerticalAlignment="Center" TextAlignment="Right" Margin="0,0,5,0" />
                    <ComboBox Width="140" HorizontalAlignment="Stretch" VerticalAlignment="Center" Style="{StaticResource ComboBoxStyle}" IsDropDownOpen="False" SelectedIndex="0">
                      <ComboBoxItem Content="Sample" />
                    </ComboBox>
                  </StackPanel>
                  <StackPanel Margin="0,0,0,5" Orientation="Horizontal">
                    <TextBlock Text="" Width="70" VerticalAlignment="Center" TextAlignment="Right" Margin="0,0,5,0" />
                    <Button Content="Reset" HorizontalAlignment="Stretch" VerticalAlignment="Center" Style="{StaticResource ButtonStyle}" />
                  </StackPanel>
                </StackPanel>
              </t:Expander>
              <!-- Preview Expander -->
              <t:Expander Header="Preview" Style="{StaticResource ExpanderStyle}">
                <Border Margin="5,0,5,5" Background="#FF333333" Height="200" CornerRadius="3,3,3,3">
                  <Grid x:Name="pnlPreview" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                  </Grid>
                </Border>
              </t:Expander>
              <!-- Debug Expander -->
              <t:Expander Header="Debug" Style="{StaticResource ExpanderStyle}">
                <StackPanel Margin="5">
                  <ComboBox x:Name="cmbExtraPanel" SelectionChanged="cmbExtraPanel_SelectionChanged" Style="{StaticResource ComboBoxStyle}">
                    <ComboBoxItem Content="None" IsSelected="True" />
                    <ComboBoxItem Content="TextBox (Notes)" />
                    <ComboBoxItem Content="DataViewer" />
                  </ComboBox>
                  <Button x:Name="btnExportXmlToNotes" Content="Create xml in notes" Margin="0,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" Style="{StaticResource ButtonStyle}" Click="btnExportXmlToNotes_Click" />
                </StackPanel>
              </t:Expander>
            </StackPanel>
          </ScrollViewer>
        </Grid>
      </Grid>
    </Grid>
  </Grid>
</UserControl>